/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view.additional;

import com.sun.lwuit.CheckBox;
import com.sun.lwuit.Component;
import com.sun.lwuit.list.ListCellRenderer;
import com.sun.lwuit.List;
import core.RegionsFilter.Pair;

/**
 *
 * @author Kvest
 */
public class CheckBoxListRenderer extends CheckBox implements ListCellRenderer
{
    public CheckBoxListRenderer()
    {
        super();
    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected)
	{
		//cast the value object into a Task
		Pair task = (Pair)value;

		//get the text of the Task and set it for this checkbox
		setText(task.getName());

		//set state of this checkbox as per 'done' variable of Task
		setSelected(task.isActive());

		//set transparency
		getStyle().setBgTransparency((byte)200);

		//set background and foreground colors
		//depending on whether the item is selected or not
		if(isSelected)
		{
			getStyle().setBgColor(0x333333);
			getStyle().setFgColor(0xffffff);
		}
		else
		{
			getStyle().setBgColor(0xffffff);
			getStyle().setFgColor(0x000000);
		}

		return this;
	}

	//initialize for drawing focus
	public Component getListFocusComponent(List list)
	{
		setText("");
		//getStyle().setBgColor(0x0000ff);
        	getStyle().setBgTransparency(80);
        	return this;
        }

	public void repaint()
	{
	}
}
